from django.contrib import admin
from django.urls import path, include, re_path
from rest_framework.authtoken import views as auth_views
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi

schema_view = get_schema_view(
   openapi.Info(
      title="知否后台 API 文档",
      default_version='v1',
      description="自动生成的接口文档",
   ),
   public=True,
   permission_classes=(permissions.AllowAny,),
)
# 看看是不是要删掉这个安装包，或是检查一下url
urlpatterns = [
    path('admin/', admin.site.urls),
    path('api-auth/', include('rest_framework.urls')),  # DRF的登录退出
    path('course/', include('course.urls')),
    path("api-token-auth/", auth_views.obtain_auth_token),

    # ✅ 文档相关接口
    re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
    path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
    path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]
